<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="NAME">rio.KeyMap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Class.create</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>  2</span> 	</span><span class="NAME">initialize</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">map</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">isMac</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>  3</span> 		</span><span class="NAME">this.map</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">map</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  4</span> 		</span><span class="NAME">this.isMac</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">isMac</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>  5</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>  6</span> 	
<span class='line'>  7</span> 	</span><span class="NAME">handle</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>  8</span> 		</span><span class="NAME">this.map.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">m</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>  9</span> 			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">map</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">m.map</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.isMac</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">m.mac</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">m.win</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 10</span> 
<span class='line'> 11</span> 			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Object.isString</span><span class="PUNC">(</span><span class="NAME">map.key</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> 
<span class='line'> 12</span> 				</span><span class="NAME">map.key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rio.KeyMap.specialKeys</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NAME">map.key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">rio.KeyMap.charCode</span><span class="PUNC">(</span><span class="NAME">map.key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 13</span> 			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 14</span> 
<span class='line'> 15</span> 			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">effectiveKeyCode</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e.keyCode</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">96</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">e.keyCode</span><span class="WHIT"> </span><span class="PUNC">&lt;=</span><span class="WHIT"> </span><span class="NUMB">105</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">e.keyCode</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">48</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">e.keyCode</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 16</span> 			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">map.key</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">effectiveKeyCode</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 17</span> 				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">map.ctrl</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">map.ctrl</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">e.ctrlKey</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 18</span> 					</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">map.alt</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">map.alt</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">e.altKey</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 19</span> 						</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">map.shift</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">map.shift</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">e.shiftKey</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 20</span> 							</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">map.meta</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">map.meta</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">e.metaKey</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 21</span> 								</span><span class="PUNC">(</span><span class="NAME">m.handler</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">Prototype.emptyFunction</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 22</span> 								
<span class='line'> 23</span> 								</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">m.stop</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 24</span> 									</span><span class="NAME">e.stop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 25</span> 								</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 26</span> 							</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 27</span> 						</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 28</span> 					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 29</span> 				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 30</span> 			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 31</span> 		</span><span class="PUNC">}</span><span class="PUNC">.</span><span class="NAME">bind</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 32</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 34</span> 
<span class='line'> 35</span> </span><span class="NAME">Object.extend</span><span class="PUNC">(</span><span class="NAME">rio.KeyMap</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 36</span> 	</span><span class="NAME">build</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">map</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 37</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">rio.KeyMap</span><span class="PUNC">(</span><span class="NAME">map</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">rio.boot.isMac</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 38</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 39</span> 	</span><span class="NAME">charCode</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 40</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"0123456789_______abcdefghijklmnopqrstuvwxyz"</span><span class="PUNC">.</span><span class="NAME">indexOf</span><span class="PUNC">(</span><span class="NAME">c</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">48</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 42</span> 	</span><span class="NAME">specialKeys</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 43</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 44</span> 			</span><span class="STRN">"left"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Event.KEY_LEFT</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 45</span> 			</span><span class="STRN">"right"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Event.KEY_RIGHT</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 46</span> 			</span><span class="STRN">"up"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Event.KEY_UP</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 47</span> 			</span><span class="STRN">"down"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Event.KEY_DOWN</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 48</span> 			</span><span class="STRN">"tab"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Event.KEY_TAB</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 49</span> 			</span><span class="STRN">"enter"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Event.KEY_RETURN</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 50</span> 			</span><span class="STRN">"home"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Event.KEY_HOME</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 51</span> 			</span><span class="STRN">"end"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Event.KEY_END</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 52</span> 			</span><span class="STRN">"backspace"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Event.KEY_BACKSPACE</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 53</span> 			</span><span class="STRN">"delete"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Event.KEY_DELETE</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 54</span> 			</span><span class="STRN">"space"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 55</span> 			</span><span class="STRN">"esc"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Event.KEY_ESC</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 56</span> 			</span><span class="STRN">","</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">188</span><span class="WHIT">
<span class='line'> 57</span> 		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 58</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 59</span> 	</span><span class="NAME">toString</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"KeyMap"</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 61</span> </span></pre></body></html>